﻿package component.formula.util;

import component.formula.FormulaInfo;

public class FormulaUtil {
	public static FormulaInfo strToFormulObj(String formula) {
		formula = formula.trim();

		int dotIndex = formula.indexOf('.');
		int leftBracketIndex = formula.indexOf('(');
		String dsName = formula.substring(0, dotIndex).trim();
		String functionName = formula.substring(dotIndex + 1,
				leftBracketIndex).trim();
		String paraExpression = formula.substring(leftBracketIndex + 1,
				formula.length() - 1).trim();

		FormulaInfo formulaInfo = new FormulaInfo();
		formulaInfo.setDsName(dsName);
		formulaInfo.setFunctionName(functionName);
		formulaInfo.setParaExpression(paraExpression);
		
		return formulaInfo;
	}
}
